/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package org.sbbs.demo.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import java.sql.Types;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.Length;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.JavaType;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.annotations.Nationalized;
import org.hibernate.type.descriptor.java.CharacterArrayJavaType;
import org.sbbs.base.jpa.entity.BaseEntity;

/**
 *
 * @author jenkins
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Entity
@Table(name = "char_string_entity")
@Comment("样例表")
public class CharStringBean extends BaseEntity {

    @Comment("姓名")
    private String name;

    // these will be mapped using CHAR
    @Comment("char包装")
    @Column(nullable = true)
    Character charWrapper;
    
    @Comment("char基础")
    @Column(nullable = true)
    char charPrimitive;

    // will be mapped using VARCHAR
    @Comment("字符串")
    @Column(nullable = true)
    String string;

// will be mapped using CLOB
    @Lob
    @Comment("字符串clob")
    @Column(nullable = true)
    String stringClob;
//下面两个之一效果相同
    @Column(length = Length.LONG)
    @Comment("字符串LONGVARCHAR")
    @JdbcTypeCode(Types.LONGVARCHAR)
    private String text;

    // will be mapped using NVARCHAR
//    @Nationalized
//    @Comment("字符串国际化")
//    String nstring;

// will be mapped using NCLOB
//    @Lob
//    @Nationalized
//    @Comment("字符串国际化nclob")
//    String nclobString;
    
//    // mapped as VARCHAR
//    @Comment("字符数组:基础")
//    @Column(nullable = true)
//    char[] charArrayPrimitive;

//    @Comment("字符数组:包装")
//    @Column(nullable = true)
//    Character[] charArrayWrapper;
//
//    @Comment("字符数组:老方法")
//    @Column(nullable = true)
//    @JavaType(CharacterArrayJavaType.class)
//    Character[] charArrayWrapperOld;

// mapped as CLOB
//    @Lob
//    @Comment("字符数组:基础clob")
//    @Column(nullable = true)
//    char[] charArrayPrimitiveClob;
//    @Lob
//    @Comment("字符数组:包装clob")
//    @Column(nullable = true)
//    Character[] charArrayWrapperClob;
}
